package com.kol.collect.config;

/**
 * Created by liukun on 20/3/6.
 */

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import com.kol.collect.interceptor.TokenInterceptor;
import com.kol.collect.interceptor.WebAuthInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 */
@Configuration
public class JwtIntercepterConfig implements WebMvcConfigurer {

    @Resource
    private TokenInterceptor tokenInterceptor;
    @Resource
    private WebAuthInterceptor webAuthInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> excludePath = new ArrayList<>();
        // 注册
        excludePath.add("/user_register");
        // 登录
        excludePath.add("/**/login");
//        excludePath.add("/login");
        // 登出
//        excludePath.add("/**/logout");
//        excludePath.add("/logout");
        // 静态资源
        excludePath.add("/static/**");
        // 静态资源
        excludePath.add("/assets/**");
//        registry.addInterceptor(tokenInterceptor).addPathPatterns("/**").excludePathPatterns(excludePath);
        registry.addInterceptor(webAuthInterceptor).addPathPatterns("/**").excludePathPatterns(excludePath);
        // WebMvcConfigurer.super.addInterceptors(registry);
    }

}